package com.assignwork.modules.corp;

import com.assignwork.dto.SafeLibrarySearchDTO;
import com.assignwork.dto.SafeLibrarySubmitDTO;
import com.assignwork.dto.ShipAgentSearchDTO;
import com.assignwork.dto.ShipAgentSubmitDTO;
import com.assignwork.service.ISafeLibraryService;
import com.assignwork.vo.SafeLibraryListVO;
import com.assignwork.vo.ShipAgentListVO;
import com.assignwork.vo.ShipAgentPageVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName SafeLibraryController
 * @Description 安全知识库前端控制器
 * @Author dujianyu
 * @Date 2023/12/24 16:16
 */
@RestController
@AllArgsConstructor
@RequestMapping("corp/safeLibrary")
public class SafeLibraryController extends BladeController {

    private ISafeLibraryService service;

    @GetMapping("/page")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<IPage<SafeLibraryListVO>> page(SafeLibrarySearchDTO dto, Query query) {
        return R.data(service.selectSafeLibraryPage(dto, Condition.getPage(query)));
    }

    @GetMapping("/list")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "列表", notes = "传入dto")
    public R<List<SafeLibraryListVO>> list(SafeLibrarySearchDTO dto) {
        return R.data(service.selectSafeLibraryList(dto));
    }

    @PostMapping("submit")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "新增或修改", notes = "传入dto")
    public R<Boolean> submitSafeLibrary(@RequestBody SafeLibrarySubmitDTO dto) {
        return R.status(service.submitSafeLibrary(dto));
    }

    @PostMapping("/remove")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "删除", notes = "传入id")
    public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String id) {
        return R.status(service.deleteLogic(Func.toLongList(id)));
    }

}
